package com.fisglobal.ewire;

import java.util.ArrayList;

public class Tag implements Cloneable
{
	private ArrayList element = new ArrayList<Element>();
	private String tagName;
	
	public Tag (String n)
	{
		tagName = n;
	}
	
	public void addElement(Element e)
	{
		element.add(e);
	}
	
	public int getElementSize()
	{
		return element.size();
	}
	
	public String getElement(int index)
	{
		return (String)element.get(index);
	}

	public ArrayList getElement()
	{
		return element;
	}

	public void setElement(ArrayList element)
	{
		this.element = element;
	}

	public String getTagName()
	{
		return tagName;
	}

	public void setTagName(String tagName)
	{
		this.tagName = tagName;
	}
	
	public String toString()
	{
		StringBuilder sb = new StringBuilder();
		sb.append(tagName);
		for (int x = 0; x < element.size(); x++)
		{
			Element ele = (Element)element.get(x);
			sb.append(ele.toString());
		}
		
		return sb.toString();
	}
	
	public Object clone()
	{
		Tag tag = new Tag(tagName);
		for (int x = 0; x < element.size(); x++)
		{
			Element ele = (Element)element.get(x);
			tag.addElement((Element)ele.clone());
		}
		return (Object)tag;
	}
	
	public Tag getCopy()
	{
		Tag tag = new Tag(tagName);
		ArrayList arrayElement = (ArrayList)element.clone();
		tag.setElement(arrayElement);
		return tag;
	}
}
